﻿using AutoMapper;
using DFGK_WMS.Context;
using DFGK_WMS.IRepository;
using DFGK_WMS.Model.DTO;
using DFGK_WMS.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.Repository
{
    public class TMaterialFoundationRepository : BaseRepository<TMaterial>, ITMaterialFoundationRepository
    {
        public TMaterialFoundationRepository(DFGK_DB context, IMapper mapper) : base(context, mapper)
        {
        }

        public bool AddBasicMaterial(FoundationMaterialDto dto)
        {
            TMaterial material = new TMaterial();
            material.Code = dto.Code;
            material.Name = dto.Name;
            material.ModelSpec = dto.ModelSpec;
            material.UnitName = dto.UnitName;
            material.UnitCode = dto.UnitCode;
            material.TypeName = dto.TypeName;
            Context.TMaterial.Add(material);
            if(Context.SaveChanges() > 0)
            {
                return true;
            }
            return false;

        }
    }
}
